package jdbctest;

import java.sql.*;

/**
 * Created by Administrator on 2017/9/11.
 */
public class Insertest {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        //加载驱动
        Class.forName("com.mysql.jdbc.Driver");
        //连接数据库
        Connection conn= DriverManager.getConnection("jdbc:mysql://localhost:3307/test","root","123456");
        //获得statement
        Statement statement=conn.createStatement();
        //执行sql（表中插入一条记录）
        String sql="insert into user(name,age) values('qq','25')";
        statement.executeUpdate(sql);
        //关闭资源
        statement.close();
        conn.close();
    }

}
